<?xml version="1.0"?>
<rss version="2.0">
  <channel><title>Using FUSE</title><link>http://bill.welliver.org//space/smartos/Using FUSE</link><description>Filesystem in Userspace (FUSE) is a mechanism that permits filesystems to be added as user-space programs, without needing to write kernel code. Support for a number of useful filesystems are available as FUSE programs(?). OI has bundled a FUSE driver and some fuse based filesystems, but most of the other illumos variants don't include this. I've put together a patch for Joyent's SmartOS that includes the necessary components for using FUSE filesytems both in the global zone and your own native zones.&lt;p class="paragraph"/&gt;
The necessary components for using FUSE filesystems are the FUSE kernel driver, libfuse and its assorted header files, and a set of programs for mounting and unmounting FUSE filesystems. You'll need a platform image built with these components, which is available here:&lt;p class="paragraph"/&gt;
&lt;span class="nobr"&gt;&lt;img height="9" width="8" src="/static/images/Icon-Extlink.png" alt="&amp;#91;external]"/&gt;&lt;a href="https://bill.welliver.org/dist/smartos/builds/fuse"&gt;https://bill.welliver.org/dist/smartos/builds/fuse&lt;/a&gt;&lt;/span&gt;&lt;p class="paragraph"/&gt;
Next, you'll need a FUSE filesystem program. I'll demonstrate using sshfs. Create a new native zone (in this case, I'm using the base64-trunk image)&lt;p class="paragraph"/&gt;
In order to use FUSE in our new zone, we need to share the fuse device with the zone, and grant the zone permission to mount fuse filesystems.&#xD;
&lt;div class="code"&gt;&lt;pre&gt;&lt;pre&gt;&#xD;
globalzone&lt;font color=brown&gt;# zonecfg -f MYZONEUUID &amp;lt;&amp;lt; EOF&#xD;
&lt;/font&gt;add device&#xD;
set match=/dev/fuse &#xD;
end&#xD;
exit&#xD;
EOF&#xD;
globalzone# vmadm update MYZONEUUID fs_allowed=&lt;i&gt;&lt;font color=darkred&gt;"fuse"&lt;/font&gt;&lt;/i&gt;&#xD;
globalzone&lt;font color=brown&gt;# vmadm reboot MYZONEUUID&#xD;
&lt;/font&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="paragraph"/&gt;
&#xD;
Now, we can build and test the sshfs FUSE filesystem in our zone:&lt;p class="paragraph"/&gt;
&lt;div class="code"&gt;&lt;pre&gt;&lt;pre&gt;&#xD;
myzone&lt;font color=brown&gt;# pkgin -y install build-essential glib2&#xD;
&lt;/font&gt;myzone# git clone https:&lt;font color=red&gt;//github.com/alhazred/illumos-sshfs&#xD;
&lt;/font&gt;myzone&lt;font color=brown&gt;# cd illumos-sshfs/sshfs-fuse/&#xD;
&lt;/font&gt;myzone# vi sshfs.c # comment out the line with &lt;i&gt;&lt;font color=darkred&gt;"g_thread_init()"&lt;/font&gt;&lt;/i&gt;&#xD;
myzone# SSHFS_CFLAGS=&lt;i&gt;&lt;font color=darkred&gt;"-I/usr/include/fuse -I/opt/local/include/glib-2.0 -I/opt/local/lib/glib-2.0/include"&lt;/font&gt;&lt;/i&gt; SSHFS_LIBS=&lt;i&gt;&lt;font color=darkred&gt;"-lfuse -lglib-2.0 -lxnet"&lt;/font&gt;&lt;/i&gt; ./configure&#xD;
myzone&lt;font color=brown&gt;# make&#xD;
&lt;/font&gt;myzone&lt;font color=brown&gt;# mkdir /tmp/sshfs-test&#xD;
&lt;/font&gt;myzone&lt;font color=brown&gt;# ./sshfs user@host:/path /tmp/sshfs-test&#xD;
&lt;/font&gt;myzone&lt;font color=brown&gt;# test out your filesystem&#xD;
&lt;/font&gt;myzone&lt;font color=brown&gt;# umount /tmp/sshfs-test&#xD;
&lt;/font&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="paragraph"/&gt;
&#xD;
We can use illumos FUSE filesystems in LX zones if the prerequisites are available. The following steps describe how to do this.&lt;p class="paragraph"/&gt;
FUSE for illumos uses pfexec to grant mount permission for non-root users when permitted. LX doesn't have pfexec, so we can put a "dummy" pfexec in the path and it will get used. We also need to make the filesystem utilities available where they're expected in the filesystem, and we can do this with a symbolic link.&lt;p class="paragraph"/&gt;
&lt;div class="code"&gt;&lt;pre&gt;&lt;pre&gt;&#xD;
mylxzone&lt;font color=brown&gt;# ln -s /native/usr/lib/fs /usr/lib/fs&#xD;
&lt;/font&gt;mylxzone&lt;font color=brown&gt;# vi /tmp/pfexec&#xD;
&lt;/font&gt;&#xD;
  &lt;font color=brown&gt;#!/bin/bash&#xD;
&lt;/font&gt;  exec $*&lt;p class="paragraph"/&gt;
mylxzone&lt;font color=brown&gt;# chmod 755 /tmp/pfexec&#xD;
&lt;/font&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="paragraph"/&gt;
&#xD;
Now, we can try to use our native sshfs. As a quick and dirty example of this, copy the illumos native sshfs binary to our new lx zone (in our case, we'll just put it in /root). We'll also need the shared libraries, which we'll copy from /opt/local/lib to /root:&lt;p class="paragraph"/&gt;
&lt;div class="code"&gt;&lt;pre&gt;&lt;pre&gt;&#xD;
sshfs&#xD;
/opt/local/lib/libglib-2.0*&#xD;
/opt/local/lib/libiconv-2*&#xD;
/opt/local/lib/libpcre-2*&#xD;
/opt/local/lib/libintl*&#xD;
&lt;/pre&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p class="paragraph"/&gt;
&#xD;
&lt;div class="code"&gt;&lt;pre&gt;&lt;pre&gt;&#xD;
mylxzone&lt;font color=brown&gt;# PATH=$PATH:/tmp:/native/usr/bin ./sshfs user@host:/path /tmp/sshfs-test&#xD;
&lt;/font&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;/div&gt;
</description><generator>Fins 0.9.7</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs></channel>
</rss>
